package cn.wolfcode.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author c1eye
 * @since 2022-11-03
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Travel implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private Long destId;

    private String destName;

    private Long authorId;

    private String title;

    private String summary;

    private String coverUrl;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date travelTime;

    private Integer avgConsume;

    private Integer day;

    private Integer person;

    private Date createTime;

    private Date releaseTime;

    private Date lastUpdateTime;

    private Integer ispublic;

    private Integer viewnum;

    private Integer replynum;

    private Integer favornum;

    private Integer sharenum;

    private Integer thumbsupnum;

    private Integer state;

    @TableField(exist = false)
    private Userinfo author;

    @TableField(exist = false)
    private TravelContent content;

    public Integer getPerExpend() {
        return avgConsume;
    }

    @TableField(exist = false)
    private String personDisplay;

    public String getPersonDisplay() {
        String res = "";
        switch (person) {
            case 1:
                res = "单人";
                break;
            case 2:
                res = "情侣";
                break;
            case 3:
                res = "家庭";
                break;
            case 4:
                res = "朋友";
                break;
            case 5:
                res = "其他";
                break;
        }
        return res;
    }

    public void setPerExpend(Integer perExpend) {
        this.avgConsume = perExpend;
    }
}
